package com.liuceng.rabbitmq.service;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.remoting.support.RemoteInvocation;
import org.springframework.remoting.support.RemoteInvocationResult;
import org.springframework.stereotype.Service;


@Service
public class RabbitmqService {
    @Autowired
    private AmqpTemplate amqpTemplateFanout;

    public void getRabbitmq(String input){
        System.out.println(input);
    }

    public void send(){
        //往名字为leo.pay.fanout.exchange的路由里面发送数据，客户端中只要是与该路由绑定在一起的队列都会收到相关消息，这类似全频广播，发送端不管队列是谁，都由客户端自己去绑定，谁需要数据谁去绑定自己的处理队列。
        for(int i = 1; i <= 10; i++) {
            String str = "hello" + i;
            amqpTemplateFanout.send("exchangeFanout", "", new Message(str.getBytes(), new MessageProperties()));
        }
    }

}
